#!/bin/bash

# Define common variables.

## Suffix of containers' name
SUFFIX=${SUFFIX:-$1}

## Docker network
CI_NETWORK=${CI_NETWORK:-ci-network}

## Openldap container's name.
LDAP_NAME=openldap
LDAP_VOLUME=openldap-volume

## Openldap image's name.
LDAP_IMAGE_NAME=${LDAP_IMAGE_NAME:-openfrontier/openldap}

## Gerrit Openldap configuration
## If there's no existing openldap server.
if [ ${#SLAPD_DOMAIN} -gt 0 -a ${#SLAPD_PASSWORD} -gt 0 ]; then
    LDAP_SERVER="${LDAP_NAME}"
    LDAP_ACCOUNTBASE="ou=accounts$(echo .${SLAPD_DOMAIN} | sed 's/\./,dc=/g')"
fi

## Gerrit administrator's ssh key
SSH_KEY_PATH=${SSH_KEY_PATH:-~/.ssh/id_rsa}

## Gerrit server and database containers' name
GERRIT_NAME=gerrit${SUFFIX}
GERRIT_VOLUME=gerrit-volume${SUFFIX}
PG_GERRIT_NAME=pg-gerrit${SUFFIX}

## Gerrit access hostname
GERRIT_WEBURL=http://${HOST_NAME}/${GERRIT_NAME}
HTTPD_LISTENURL=proxy-http://*:8080/${GERRIT_NAME}
GERRIT_SSH_HOST=${HOST_NAME}

## Gerrit docker image's name
GERRIT_IMAGE_NAME=${GERRIT_IMAGE_NAME:-openfrontier/gerrit-ci}

## Jenkins container's name
JENKINS_NAME=jenkins${SUFFIX}
JENKINS_VOLUME=jenkins-volume${SUFFIX}

## Jenkins start options
JENKINS_OPTS=--prefix=/${JENKINS_NAME}

## Jenkins docker image's name
JENKINS_IMAGE_NAME=${JENKINS_IMAGE_NAME:-openfrontier/jenkins}

## Jenkins access
JENKINS_WEBURL=http://${HOST_NAME}/${JENKINS_NAME}

## Redmine container's name
REDMINE_NAME=redmine${SUFFIX}
REDMINE_VOLUME=redmine-volume${SUFFIX}
PG_REDMINE_NAME=pg-redmine${SUFFIX}

## Redmine docker image's name
REDMINE_IMAGE_NAME=${REDMINE_IMAGE_NAME:-sameersbn/redmine:nodel}

## Nginx docker container's name
NGINX_NAME=proxy

## Nginx docker image's name
# Fixme: remove noredmine tag when redmine can come up
NGINX_IMAGE_NAME=${NGINX_IMAGE_NAME:-openfrontier/nginx:latest}

## Nginx file upload limit.
NGINX_MAX_UPLOAD_SIZE=${NGINX_MAX_UPLOAD_SIZE:-200m}

## Default Nexus URL
if [ ${#NEXUS_WEBURL} -gt 0 ]; then
    NEXUS_REPO=${NEXUS_WEBURL}/content/groups/public
else
    NEXUS_REPO=http://nexus:8081/nexus/content/groups/public
fi

## Nexus container's name.
NEXUS_NAME=nexus
NEXUS_VOLUME=nexus-volume

# Nexue docker image's name.
NEXUS_IMAGE_NAME=${NEXUS_IMAGE_NAME:-openfrontier/nexus}
